<?php
/**
 * Jishupu-Laravel-Vue-Admin
 * @Author:技术铺<jishupu@qq.com>
 * @Date: 2021/11/22
 */
namespace App\Models;

use App\Traits\BaseModel;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

/**
 * 角色菜单权限模型
 * Class RoleMenuPermission
 * @package App\Models
 */
class RoleMenuPermission extends Model
{
    use BaseModel, HasFactory;

    /**
     * 指定表名
     */
    protected $table = 'role_menu_permission';

    /**
     * 能批量赋值的属性
     *
     * @var string[]
     */
//    protected $fillable = [];

    /**
     * 不能被批量赋值的属性
     *
     * @var array
     */
    protected $guarded = [];

    /**
     * 数据显示时，设置了敏感信息字段数据中不显示
     *
     * @var array
     */
    protected $hidden = [
        'deleted_at',
        'created_at',
        'updated_at',
        'created_user_id'
    ];

    /**
     * 显示数据时类型转换
     *
     * @var array
     */
    protected $casts = [
    ];

    /**
     * 关联菜单表
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function menu()
    {
        return $this->belongsTo(Menu::class, 'menu_id', 'id');
    }

    /**
     * 关联权限表
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function permission()
    {
        return $this->belongsTo(Permission::class, 'permission_id', 'id');
    }
}
